package com.jacob.cloud.mall.common.exception;

/**
 * 异常枚举
 */
public enum MallExceptionEnum {

    // 用户模块
    NEED_USER_NAME(10001, "用户名不能为空"),
    NEED_PASSWORD(10002, "用户密码不能为空"),
    NEED_PASSWORD_LENGTH_8(10003, "密码长度最小为8"),
    NAME_EXIST(10004, "用户名已存在"),
    WRONG_PASS(10005, "用户名或密码错误"),
    NEED_LOGIN(10006, "用户未登录"),
    NEED_ADMIN(10007, "无管理员权限"),

    CATEGORY_NAME_EXIST(11001, "分类名已存在"),
    CATEGORY_NOT_EXIST(11002, "目录不存在"),

    // 商品相关
    PRODUCT_NAME_EXIST(12001, "商品名已存在"),
    PRODUCT_NOT_EXIST(12002, "商品不存在"),

    // 购物车相关
    CART_PRODUCT_NOT_SELL(12003, "商品状态异常，无法添加到购物车"),
    CART_NOT_ENOUGH(12004, "商品库存不足"),
    CART_EMPTY(12005, "购物车已勾选的商品为空"),

    // 订单相关
    ORDER_NOT_EXIST(13001, "订单不存在"),
    ORDER_NOT_YOUR(13002, "订单不属性与你"),
    ORDER_STATUS_WRONG(13003, "订单状态不符"),

    INSERT_FAIL(20001, "新增失败"),
    UPDATE_FAIL(20002, "修改失败"),
    DELETE_FAIL(20003, "删除失败"),
    MKDIR_FAIL(20003, "新建文件夹错误"),
    UPLOAD_FAIL(20003, "文件上传失败"),

    SYSTEM_ERROR(30000, "系统异常"),
    REQUEST_ARGUMENT_ERROR(30001, "参数错误"),
    NO_ENUM(30002, "未找到对应的枚举信息");



    /** 异常码 */
    Integer code;

    /** 异常信息 */
    String msg;

    MallExceptionEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
